package com.itheima.exception;


import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@Component
@ControllerAdvice
public class ExceptionAdvice {

    @ExceptionHandler(NullPointerException.class)
    @ResponseBody
    public String doNullPointerException(Exception e){
        return "空指针异常";
    }


    @ExceptionHandler(ArithmeticException.class)
    @ResponseBody
    public String doArithmeticException(Exception e){
        return "算术运算异常";
    }



    @ExceptionHandler(Exception.class)
    @ResponseBody
    public String doException(Exception e){
        return "all";
    }


}
